package com.jetgege.smartbox.Base;

import android.app.Application;
import android.bluetooth.BluetoothDevice;
import android.content.Context;
import android.content.SharedPreferences;

import com.jetgege.smartbox.Model.BlueModel;
import com.jetgege.smartbox.Model.DeviceModel;
import com.jetgege.smartbox.Model.UserModel;

import java.util.ArrayList;
import java.util.List;


/**
 * Created by JJT-ssd on 2017/4/21.
 */

public class App extends Application{

    public static Context mContext;

    //获取数据初始设置
    public static SharedPreferences preferences;
    public static SharedPreferences.Editor editor;

    //我的设备列表
    public static BlueModel mBlueModel;
    public static UserModel mUser;
    public static DeviceModel mDevices;
    public static BluetoothDevice connectedDevices;
    BluetoothDevice mConnectedDevices;
    private List<UserModel> userModels = new ArrayList<>();
    @Override
    public void onCreate() {
        super.onCreate();
        initValue();
    }

    private void initValue()
    {
        this.mContext= getApplicationContext();


        //获取数据初始设置
        preferences = getSharedPreferences("preferences",MODE_PRIVATE);
        editor =preferences.edit();
        mBlueModel =new BlueModel();
        //测试数据
        mUser = new UserModel();
        mUser.setPhoneNum("1007");
        mUser.setUserName("admin");
        mDevices = new DeviceModel();
        mDevices.setDeviceID("22222");
        mDevices.setDeviceName("Device" );

        for (int j=0;j<5;j++) {
            UserModel model = new UserModel();
            model.setPhoneNum(String.valueOf(1007+j));
            model.setUserName("jet" + String.valueOf(j));
            model.setFrigerNum(2);
            userModels.add(model);
            if (model.getPhoneNum().equals("1007")){
                model.setUserType(1);//管理员
            }else  model.setUserType(2);
            mDevices.setUserModels(userModels);
        }


    }
}
